<?php

class DB extends DBCONFIG {

    var $connection = null;

    function __construct() {
        $this->connection = new mysqli($this->host, $this->user,
                $this->pass, $this->db, $this->port);

        if ($this->connection->connect_error) {
        die('MySQL Error (' . $this->connection->connect_errno . ') '
                . $this->connection->connect_error);
        }
    }

    function __destruct() {
        $this->connection->close();
    }

    function getStmt($sql) {
        $stmt = $this->connection->stmt_init();

        if (!$stmt->prepare($sql)) {
            exit("Error preparing statement: " . $stmt->error);
        }

        return $stmt;
    }

    function _execute(&$stmt) {
        if (!$stmt->execute()) {
            exit("Error executing statement: " . $stmt->error);
        }
        return true;
    }
}
?>